﻿@model IEnumerable<SAD.Models.Account>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
    ViewBag.Title = "Users List";
    string role;

    //get role
    if (Session["Role"] == null)
    {
        role = "user";
    }
    else
    {
        role = Session["role"].ToString();
    }
}
<h2>Users List</h2>

@{
    if (role == "admin")
    {
        <table>
            <tr>
                <th>
                    username
                </th>
                <th>
                    password
                </th>
                <th>
                    fullname
                </th>
                <th>
                    address
                </th>
                <th>
                    phone
                </th>
                <th>
                    role
                </th>
                <th></th>
            </tr>

        @foreach (var item in Model) {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.accountID)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.password)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.fullname)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.address)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.phone)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.role)
                </td>
                <td>
                    @Html.ActionLink("Update", "Update", new { id=item.accountID }) |
                    @Html.ActionLink("Details", "Details", new { id=item.accountID }) |
                    @Html.ActionLink("Delete", "Delete", new { id=item.accountID })
                </td>
            </tr>
        }

        </table>

    }
    else
    {
        <h2>You don't have permission to enter this page.</h2>
    }
}
